function [trainingset testset] = sampleSet(Matrix, samplefraction, RndSeed)
    
    % first randomize the data   
    stream = RandStream('mt19937ar', 'Seed', RndSeed);
    Indices = randperm(stream,length(Matrix));
    
    %calculate the amount of data used for training
    samplesize = floor(length(Indices)*samplefraction);
    
    %Split the set
    IndLearn = Indices(1:samplesize);
    IndTest = Indices(samplesize+1:length(Indices));
    trainingset = Matrix(IndLearn, :);
    testset = Matrix(IndTest, :);
end